Skip to content

test(metrics): reset Datadog metrics and default tags between test runs (#8872) - #8878

Open
dhaiirryyaa wants to merge 1 commit into
aws-powertools:developfrom
dhaiirryyaa:fix/datadog-test-metric-reset
Open

dhaiirryyaa wants to merge 1 commit into
aws-powertools:developfrom
dhaiirryyaa:fix/datadog-test-metric-reset

Conversation

@dhaiirryyaa

Copy link
Copy Markdown
Contributor

Issue number: closes #8872

Summary

Changes

In tests/functional/metrics/conftest.py, clear Datadog metrics and default tags in the autouse fixture reset_metric_set:

  • Added DatadogMetrics().clear_metrics()
  • Added DatadogMetrics().clear_default_tags()

User experience

Running unit tests before functional tests (such as pytest tests/unit/metrics/test_unit_datadog.py tests/functional/metrics/datadog) no longer leaves unflushed metrics (metric_2) in the shared DatadogMetrics._metrics class buffer, preventing JSONDecodeError: Extra data failures during subsequent Datadog functional test flushes.

Verification


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dhaiirryyaa

dhaiirryyaa commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @leandrodamascena @Manishram-ai, this PR is ready for review. It ensures DatadogMetrics buffers and default tags are reset in tests/functional/metrics/conftest.py, preventing test order dependent failures when unit tests run before functional tests, resolving #8872. All 180 metrics tests pass and ruff is clean. Thank you!

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.20%. Comparing base (a2eb4d5) to head (67cc57d).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8878   +/-   ##
========================================
  Coverage    97.20%   97.20%           
========================================
  Files          327      327           
  Lines        16759    16759           
  Branches      1523     1523           
========================================
  Hits         16290    16290           
  Misses         328      328           
  Partials       141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: Datadog functional test fails when unit tests run first (shared metric buffer not reset)

1 participant